<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="10" :lg="11" :md="12" :sm="24">
            <a-form-item :label="$t('时间')">
              <a-date-picker
                :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }"
                valueFormat="YYYY-MM-DD HH:mm:ss"
                :placeholder="$t('请选择开始时间')"
                class="query-group-cust"
                v-model="queryParam.bTime"
              ></a-date-picker>
              <span class="query-group-split-cust"></span>
              <a-date-picker
                :show-time="{ defaultValue: moment('23:59:59', 'HH:mm:ss') }"
                valueFormat="YYYY-MM-DD HH:mm:ss"
                :placeholder="$t('请选择结束时间')"
                class="query-group-cust"
                v-model="queryParam.eTime"
              ></a-date-picker>
            </a-form-item>
          </a-col>
          <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24" v-if="!tenantid">
            <a-form-item :label="$t('门店')">
              <a-select v-model="queryParam.shopCode">
                <a-select-option v-for="(item,i) in shops" :key="i" :value="item.value">{{item.title}}<span v-if="item.value != ''">（{{item.value}}）</span></a-select-option>
              </a-select>
            </a-form-item>
          </a-col> -->
          <a-col :xl="10" :lg="12" :md="12" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">{{$t('查询')}}</a-button>
              <a-dropdown>
                <a-menu slot="overlay" @click="handleDateClick">
                  <a-menu-item key="1"> {{$t('今日')}} </a-menu-item>
                  <a-menu-item key="2"> {{$t('近三天')}} </a-menu-item>
                  <a-menu-item key="3"> {{$t('近七天')}} </a-menu-item>
                  <a-menu-item key="4"> {{$t('近一月')}} </a-menu-item>
                  <a-menu-item key="5"> {{$t('近三月')}} </a-menu-item>
                  <a-menu-item key="6"> {{$t('近半年')}} </a-menu-item>
                  <a-menu-item key="7"> {{$t('本年')}} </a-menu-item>
                </a-menu>
                <a-button type="primary" style="margin-left: 8px"> {{ $t('快捷查询') }} <a-icon type="down" /></a-button>
              </a-dropdown>
              <a-button type="primary" style="margin-left: 8px" @click="handleExportXls($t('场地报表'))" v-has="'ShopAReportController:export'">{{
                $t('导出')
              }}</a-button>
              <a-button type="primary" style="margin-left: 8px" @click="handlePrint" v-has="'ShopAReportController:print'">{{ $t('打印') }}</a-button>
              <a-popover :title="$t('自定义模块')" trigger="click" placement="bottom">
                <template slot="content">
                  <a-checkbox-group
                    @change="onColSettingsChange"
                    v-model="settingModules"
                    :defaultValue="settingModules"
                  >
                    <a-row style="width: 400px">
                      <template v-for="(item, i) in defModules">
                        <a-col :span="12" :key="i"
                          ><a-checkbox :value="item.value"
                            ><j-ellipsis :value="item.title" :length="10"></j-ellipsis></a-checkbox
                        ></a-col>
                      </template>
                    </a-row>
                  </a-checkbox-group>
                </template>
                <a-button type="setting" style="margin-left: 8px">{{ $t('设置模块') }}</a-button>
              </a-popover>
            </span>
          </a-col>
          <template v-if="toggleSearchStatus"></template>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!-- table区域-begin -->
    <div style="width:1200px">
      <div v-if="modules.findIndex(m=>{return m.value=='1'})>-1 && equipmentCollectionDataSource.length > 0">
        <div style="font-weight: 600; margin: 10px 0">{{ $t('设备收款汇总') }}</div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          class="j-table-force-nowrap"
          :scroll="{ x: true }"
          :columns="equipmentCollectionColumns"
          :dataSource="equipmentCollectionDataSource"
          :pagination="false"
          :loading="loading"
          :customHeaderRow="customHeaderRow"
          :customRow="(r, i)=>customRow(r,i,'a')"
        >
          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>
          <template slot="imgSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
            <img
              v-else
              :src="getImgView(text)"
              height="25px"
              alt
              style="max-width: 80px; font-size: 12px; font-style: italic"
            />
          </template>
          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
            <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">{{
              $t('下载')
            }}</a-button>
          </template>
        </a-table>
      </div>
      <div v-if="modules.findIndex(m=>{return m.value=='2'})>-1 && businessSummaryDataSource.length > 0">
        <div style="font-weight: 600; margin: 10px 0">{{ $t('业务汇总') }}</div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          class="j-table-force-nowrap"
          :scroll="{ x: true }"
          :columns="businessSummaryColumns"
          :dataSource="businessSummaryDataSource"
          :pagination="false"
          :loading="loading"
          :customHeaderRow="customHeaderRow"
          :customRow="(r, i)=>customRow(r,i,'b')"
        >
          <template slot="typeId" slot-scope="text, record">
            <span v-if="record.typeId != '8'">{{ text }}</span>
            <a v-else @click.stop="viewDetail(record)">{{ text }}</a>
          </template>
          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>
          <template slot="imgSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
            <img
              v-else
              :src="getImgView(text)"
              height="25px"
              alt
              style="max-width: 80px; font-size: 12px; font-style: italic"
            />
          </template>
          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
            <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">{{
              $t('下载')
            }}</a-button>
          </template>
        </a-table>
      </div>
      <div v-if="modules.findIndex(m=>{return m.value=='3'})>-1 && goodsSalesDataSource.length > 1">
        <div style="font-weight: 600; margin: 10px 0">{{ $t('商品销售兑换') }}</div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          class="j-table-force-nowrap"
          :scroll="{ x: true }"
          :columns="goodsSalesColumns"
          :dataSource="goodsSalesDataSource"
          :pagination="false"
          :loading="loading"
          :customHeaderRow="customHeaderRow"
          :customRow="(r, i)=>customRow(r,i,'c')"
        >
          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>
          <template slot="imgSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
            <img
              v-else
              :src="getImgView(text)"
              height="25px"
              alt
              style="max-width: 80px; font-size: 12px; font-style: italic"
            />
          </template>
          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
            <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">{{
              $t('下载')
            }}</a-button>
          </template>
        </a-table>
      </div>
      <div v-if="modules.findIndex(m=>{return m.value=='4'})>-1 && machineOnOffDataSource.length > 1">
        <div style="font-weight: 600; margin: 10px 0">{{ $t('机台投币退票') }}</div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          class="j-table-force-nowrap"
          :scroll="{ x: true }"
          :columns="machineOnOffColumns"
          :dataSource="machineOnOffDataSource"
          :pagination="false"
          :loading="loading"
          :customHeaderRow="customHeaderRow"
          :customRow="(r, i)=>customRow1(r,i,'d')"
        >
          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>
          <template slot="imgSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
            <img
              v-else
              :src="getImgView(text)"
              height="25px"
              alt
              style="max-width: 80px; font-size: 12px; font-style: italic"
            />
          </template>
          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
            <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">{{
              $t('下载')
            }}</a-button>
          </template>
        </a-table>
      </div>
      <div v-if="modules.findIndex(m=>{return m.value=='5'})>-1 && ticketProjectDataSource.length > 1">
        <div style="font-weight: 600; margin: 10px 0">{{ $t('门票汇总') }}</div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          class="j-table-force-nowrap"
          :scroll="{ x: true }"
          :columns="ticketProjectColumns"
          :dataSource="ticketProjectDataSource"
          :pagination="false"
          :loading="loading"
          :customHeaderRow="customHeaderRow"
          :customRow="(r, i)=>customRow(r,i,'e')"
        >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">{{
            $t('下载')
          }}</a-button>
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click.stop="handleDetail(record)">{{ $t('详情') }}</a>
        </span>
      </a-table>
      </div>
      <div v-if="modules.findIndex(m=>{return m.value=='6'})>-1 && balanceChangesDataSource.length > 0">
        <div style="font-weight: 600; margin: 10px 0">{{ $t('会员余额变化') }}</div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          class="j-table-force-nowrap"
          :scroll="{ x: true }"
          :columns="balanceChangesColumns"
          :dataSource="balanceChangesDataSource"
          :pagination="false"
          :loading="loading"
          :customHeaderRow="customHeaderRow"
          :customRow="(r, i)=>customRow(r,i,'f')"
        >
          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>
          <template slot="tipSlot" slot-scope="text">
            <span style="font-size: 14px;">{{ text }}</span>
            <a-tooltip>
              <template slot="title">{{
                $t(
                  '上一个账期的期末'
                )
              }}</template>
              <a-icon type="question-circle" v-if="text == $t('期初')" style="margin-left: 5px" />
            </a-tooltip>
            <a-tooltip>
              <template slot="title">{{
                $t(
                  '查询时间内会员账户累计增加的值'
                )
              }}</template>
              <a-icon type="question-circle" v-if="text == $t('本期增')" style="margin-left: 5px" />
            </a-tooltip>
            <a-tooltip>
              <template slot="title">{{
                $t(
                  '查询时间内会员账户累计减少的值'
                )
              }}</template>
              <a-icon type="question-circle" v-if="text == $t('本期减')" style="margin-left: 5px" />
            </a-tooltip>
            <a-tooltip>
              <template slot="title">{{
                $t(
                  '变化值=期末-期初；即查询时间内账户的变化，也就是会员业务明细中相同查询时间段内的交易汇总。'
                )
              }}</template>
              <a-icon type="question-circle" v-if="text == $t('变化值')" style="margin-left: 5px" />
            </a-tooltip>
            <a-tooltip>
              <template slot="title">{{
                $t(
                  '期末=期初+本期增-本期减'
                )
              }}</template>
              <a-icon type="question-circle" v-if="text == $t('期末')" style="margin-left: 5px" />
            </a-tooltip>
            
          </template>
          <template slot="imgSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
            <img
              v-else
              :src="getImgView(text)"
              height="25px"
              alt
              style="max-width: 80px; font-size: 12px; font-style: italic"
            />
          </template>
          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
            <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">{{
              $t('下载')
            }}</a-button>
          </template>
        </a-table>
      </div>
      <div v-if="modules.findIndex(m=>{return m.value=='7'})>-1 && memberMealDataSource.length > 0">
        <div style="font-weight: 600; margin: 10px 0">{{ $t('套餐汇总') }}</div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          class="j-table-force-nowrap"
          :scroll="{ x: true }"
          :columns="memberMealColumns"
          :dataSource="memberMealDataSource"
          :pagination="false"
          :loading="loading"
          :customHeaderRow="customHeaderRow"
          :customRow="(r, i)=>customRow(r,i,'g')"
        >
          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>
          <template slot="imgSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
            <img
              v-else
              :src="getImgView(text)"
              height="25px"
              alt=""
              style="max-width: 80px; font-size: 12px; font-style: italic"
            />
          </template>
          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
            <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
              {{ $t('下载') }}
            </a-button>
          </template>
        </a-table>
      </div>
      <div v-if="modules.findIndex(m=>{return m.value=='8'})>-1 && outCoinDataSource.length > 0">
        <div style="font-weight: 600; margin: 10px 0">{{ $t('设备出币') }}</div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          class="j-table-force-nowrap"
          :scroll="{ x: true }"
          :columns="outCoinColumns"
          :dataSource="outCoinDataSource"
          :pagination="false"
          :loading="loading"
          :customHeaderRow="customHeaderRow"
          :customRow="(r, i)=>customRow(r,i,'h')"
        >
          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>
          <template slot="imgSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
            <img
              v-else
              :src="getImgView(text)"
              height="25px"
              alt=""
              style="max-width: 80px; font-size: 12px; font-style: italic"
            />
          </template>
          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
            <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
              {{ $t('下载') }}
            </a-button>
          </template>
        </a-table>
      </div>
      <div v-if="modules.findIndex(m=>{return m.value=='9'})>-1 && saveLotteryDataSource.length > 1">
        <div style="font-weight: 600; margin: 10px 0">{{ $t('存票汇总') }}</div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="deviceId"
          class="j-table-force-nowrap"
          :scroll="{ x: true }"
          :columns="saveLotteryColumns"
          :dataSource="saveLotteryDataSource"
          :pagination="false"
          :loading="loading"
          :customHeaderRow="customHeaderRow"
          :customRow="(r, i)=>customRow(r,i,'l')"
        >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">{{
            $t('下载')
          }}</a-button>
        </template>
      </a-table>
      </div>
      <div v-if="modules.findIndex(m=>{return m.value=='10'})>-1 && giftRecycleDataSource.length > 1">
        <div style="font-weight: 600; margin: 10px 0">{{ $t('礼品回收') }}</div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="kindId"
          class="j-table-force-nowrap"
          :scroll="{ x: true }"
          :columns="giftRecycleColumns"
          :dataSource="giftRecycleDataSource"
          :pagination="false"
          :loading="loading"
          :customHeaderRow="customHeaderRow"
          :customRow="(r, i)=>customRow(r,i,'m')"
        >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">{{
            $t('下载')
          }}</a-button>
        </template>
      </a-table>
      </div>
      <div v-if="modules.findIndex(m=>{return m.value=='11'})>-1 && goodsKindDataSource.length > 1">
        <div style="font-weight: 600; margin: 10px 0">{{ $t('商品分类') }}</div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="kindId"
          class="j-table-force-nowrap"
          :scroll="{ x: true }"
          :columns="goodsKindColumns"
          :dataSource="goodsKindDataSource"
          :pagination="false"
          :loading="loading"
          :customHeaderRow="customHeaderRow"
          :customRow="(r, i)=>customRow(r,i,'n')"
        >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">{{
            $t('下载')
          }}</a-button>
        </template>
      </a-table>
      </div>
    </div>
    <site-report-print ref="printPreview" />
    <share-detail-modal ref="sDtlModal"></share-detail-modal>
  </a-card>
</template>

<script>
import Vue from 'vue'
import moment from 'moment'
import '@/assets/less/TableExpand.less'
import { getAction, downFile } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { initDictOptions, filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import SiteReportPrint from './modules/SiteReportPrint'
import ShareDetailModal from '../finance/modules/ShareDetailModal'

export default {
  name: 'SiteReport',
  mixins: [JeecgListMixin],
  components: {
    SiteReportPrint,
    ShareDetailModal
  },
  data() {
    return {
      moment,
      description: '场地收款报表页面',
      // 表头
      equipmentCollectionColumns: [],
      equipmentCollectionDataSource: [],
      businessSummaryColumns: [
        {
          title: this.$t('业务类型'),
          align: 'center',
          dataIndex: 'typeId_dictText',
          scopedSlots: { customRender: 'typeId' },
        },
        {
          title: this.$t('业务笔数'),
          align: 'center',
          dataIndex: 'count',
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
            return text.toFixed(0);
          }
        },
        {
          title: this.$t('金额'),
          align: 'center',
          dataIndex: 'cash',
          customRender: (t, r, i) => {
            if (!t) {
              t = 0
            }
            return t.toFixed(2)
          },
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('实币'),
          align: 'center',
          dataIndex: 'phyCoin',
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
            return text.toFixed(0);
          }
        },
      ],
      businessSummaryDataSource: [],
      goodsSalesColumns: [
        {
          title: this.$t('商品名称'),
          align: 'center',
          dataIndex: 'goodsName',
          customRender: (t, r, i) => {
            if (!t) {
              t = this.$t('合计')
            }
            return t
          },
        },
        {
          title: this.$t('数量'),
          align: 'center',
          dataIndex: 'totalNum',
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
            return text.toFixed(0);
          }
        },
        {
          title: this.$t('销售金额'),
          align: 'center',
          dataIndex: 'sale',
          customRender: (t, r, i) => {
            if (!t) {
              t = 0
            }
            return t.toFixed(2)
          },
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
      ],
      goodsSalesDataSource: [],
      machineOnOffColumns: [
        {
          title: this.$t('项目名称'),
          align: 'center',
          dataIndex: 'gameId_dictText',
        },
        {
          title: this.$t('支付金额'),
          align: 'center',
          dataIndex: 'payAmount',
          customRender: (t, r, i) => {
            if (!t) {
              t = 0
            }
            return t.toFixed(2)
          },
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('卡投币'),
          align: 'center',
          dataIndex: 'memberCoin',
          customRender: (t, r, i) => {
            if (!t) {
              t = 0
            }
            return t.toFixed(2)
          },
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('投实币'),
          align: 'center',
          dataIndex: 'physicalCoin',
          customRender: (t, r, i) => {
            if (!t) {
              t = 0
            }
            return t.toFixed(2)
          },
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('总投币'),
          align: 'center',
          dataIndex: 'totalCoin',
          customRender: (t, r, i) => {
            if (!t) {
              t = 0
            }
            return t.toFixed(2)
          },
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        // {
        //   title: this.$t('退票类型'),
        //   align: 'center',
        //   dataIndex: 'outputType_dictText',
        // },
        {
          title: this.$t('退票值'),
          align: 'center',
          dataIndex: 'outputValue',
          customRender: (t, r, i) => {
            if (!t) {
              t = 0
            }
            return t.toFixed(2)
          },
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
      ],
      machineOnOffDataSource: [],
      ticketProjectColumns:[
      {
          title: this.$t('项目名称'),
          align: 'center',
          dataIndex: 'goodsName',
          customRender: (t, r) => {
            if (t == '合计') {
              return this.$t(t)
            }
            return t
          },
        },
        {
          title: this.$t('销售数量'),
          align: 'center',
          dataIndex: 'saleNum',
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
            return text.toFixed(0);
          }
        },
        {
          title: this.$t('销售金额'),
          align: 'center',
          dataIndex: 'sale',
          customRender: (t) => {
            return t.toFixed(2)
          },
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('扣年月票张数'),
          align: 'center',
          dataIndex: 'deductNum',
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
            return text.toFixed(0);
          }
        },
      ],
      ticketProjectDataSource: [],
      balanceChangesColumns: [
        // {
        //   title: '',
        //   align: 'center',
        //   dataIndex: 'name',
        // },
        {
            title:'',
            align:"center",
            dataIndex: 'name',
            scopedSlots: {customRender: 'tipSlot'}
          },
        {
          title: this.$t('会员数量'),
          align: 'center',
          dataIndex: 'member',
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
            return text.toFixed(0);
          }
        },
      ],
      balanceChangesDataSource: [],
      memberMealColumns: [{
        title: this.$t('商品名称'),
        align: 'center',
        dataIndex: 'goodsName',
        scopedSlots: { customRender: 'goodsName' },
        customCell: (r) => {
          if (r.goodsName == this.$t('合计')) {
            return {
              attrs: {
                colSpan: 2,
              },
            }
          }
          return {
            attrs: {
              colSpan: 1,
            },
          }
        },
      },
      {
        title: this.$t('套餐单价'),
        align: 'center',
        dataIndex: 'avgPrice',
        customRender: (text, row, index) => {
          if (row.goodsName != this.$t('合计')) {
            if (!text) {
              return 0.00;
            }
            return text.toFixed(2)
          }
          return {
            attrs: {
              colSpan: 0,
            },
          }
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      },
      {
        title: this.$t('业务笔数'),
        align: 'center',
        dataIndex: 'count',
        customRender: (text, r) => {
          if (!text) {
            return 0;
          }
          return text.toFixed(0);
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      },
      {
        title: this.$t('销售数量'),
        align: 'center',
        dataIndex: 'saleNum',
        customRender: (text, r) => {
          if (!text) {
            return 0;
          }
          return text.toFixed(0);
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      },
      {
        title: this.$t('销售金额'),
        align: 'center',
        dataIndex: 'sale',
        customRender: (t) => {
          if (!t) {
            return 0.00;
          }
          return t.toFixed(2)
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      },
      {
        title: this.$t('币值'),
        align: 'center',
        dataIndex: 'coin',
        customRender: (text, r) => {
          if (!text) {
            return 0;
          }
          return text.toFixed(0);
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      },
      {
        title: this.$t('售币值'),
        align: 'center',
        dataIndex: 'saleCoin',
        customRender: (text, r) => {
          if (!text) {
            return 0;
          }
          return text.toFixed(0);
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      },
      {
        title: this.$t('充币值'),
        align: 'center',
        dataIndex: 'rechargeCoin',
        customRender: (text, r) => {
          if (!text) {
            return 0;
          }
          return text.toFixed(0);
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      },
      {
        title: this.$t('限时币'),
        align: 'center',
        dataIndex: 'limitCoin',
        customRender: (text, r) => {
          if(!text){
              return 0;
            }
          return text.toFixed(0);
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      },
      ],
      memberMealDataSource: [],
      outCoinColumns:[
        {
          title: this.$t('设备编码'),
          align: 'center',
          dataIndex: 'deviceId',
        },
        {
          title: this.$t('设备名称'),
          align: 'center',
          dataIndex: 'deviceName',
        },
        {
          title: this.$t('设备类型'),
          align: 'center',
          dataIndex: 'deviceType_dictText',
        },
        {
          title: this.$t('笔数'),
          align: 'right',
          dataIndex: 'count',
          customRender: (text, r) => {
            return text.toFixed(0);
          }
        },
        {
          title: this.$t('出币值'),
          align: 'right',
          dataIndex: 'amount',
          customRender: (text, r) => {
            return text.toFixed(0);
          }
        },
      ],
      outCoinDataSource: [],
      saveLotteryColumns: [
        {
          title: this.$t('设备编码'),
          align: 'center',
          dataIndex: 'deviceId',
          customRender:(t,r)=>{
            if(t=='合计'){
              return this.$t(t)
            }
            return t
          }
        },
        {
          title: this.$t('设备名称'),
          align: 'center',
          dataIndex: 'deviceName',
        },
        {
          title: this.$t('设备类型'),
          align: 'center',
          dataIndex: 'deviceType_dictText',
        },
        {
          title: this.$t('存币次数'),
          align: 'center',
          dataIndex: 'coinCount',
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
            return text.toFixed(0);
          }
        },
        {
          title: this.$t('存币值'),
          align: 'center',
          dataIndex: 'coin',
          customCell: () => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
            return text.toFixed(2);
          }
        },
        {
          title: this.$t('存票次数'),
          align: 'center',
          dataIndex: 'lotteryCount',
          customCell: () => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
            return text.toFixed(0);
          }
        },
        {
          title: this.$t('存票值'),
          align: 'center',
          dataIndex: 'lottery',
          customCell: () => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
            return text.toFixed(0);
          }
        },
      ],
      saveLotteryDataSource: [],
      giftRecycleColumns: [
        {
          title: this.$t('商品编码'),
          align: 'center',
          dataIndex: 'goodsCode',
        },
        {
          title: this.$t('商品名称'),
          align: 'center',
          dataIndex: 'goodsName',
          customRender: (t, r) => {
            if (t == '合计') {
              return this.$t(t)
            }
            return t
          },
        },
        {
          title: this.$t('商品分类'),
          align: 'center',
          dataIndex: 'goodsKindName',
        },
        {
          title: this.$t('回收币'),
          align: 'center',
          children: [
            {
              title: this.$t('数量'),
              align: 'center',
              dataIndex: 'coinNumber',
              customCell: (r, i) => {
                return {
                  style: {
                    textAlign: 'right',
                  },
                }
              },
              customRender: (text, r) => {
                text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
                return text.toFixed(0);
              }
            },
            {
              title: this.$t('币值'),
              align: 'center',
              dataIndex: 'coin',
              customCell: (r, i) => {
                return {
                  style: {
                    textAlign: 'right',
                  },
                }
              },
              customRender: (text, r) => {
                text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
                return text.toFixed(2);
              }
            },
          ],
        },
        {
          title: this.$t('回收彩票'),
          align: 'center',
          children: [
            {
              title: this.$t('数量'),
              align: 'center',
              dataIndex: 'lotteryNumber',
              customCell: (r, i) => {
                return {
                  style: {
                    textAlign: 'right',
                  },
                }
              },
              customRender: (text, r) => {
                text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
                return text.toFixed(0);
              }
            },
            {
              title: this.$t('彩票'),
              align: 'center',
              dataIndex: 'lottery',
              customCell: (r, i) => {
                return {
                  style: {
                    textAlign: 'right',
                  },
                }
              },
              customRender: (text, r) => {
                text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
                return text.toFixed(0);
              }
            },
          ],
        },
        {
          title: this.$t('回收积分'),
          align: 'center',
          children: [
            {
              title: this.$t('数量'),
              align: 'center',
              dataIndex: 'integralNumber',
              customCell: (r, i) => {
                return {
                  style: {
                    textAlign: 'right',
                  },
                }
              },
              customRender: (text, r) => {
                text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
                return text.toFixed(0);
              }
            },
            {
              title: this.$t('积分'),
              align: 'center',
              dataIndex: 'integral',
              customCell: (r, i) => {
                return {
                  style: {
                    textAlign: 'right',
                  },
                }
              },
              customRender: (text, r) => {
                text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
                return text.toFixed(0);
              }
            },
          ],
        },
        {
          title: this.$t('回收A票'),
          align: 'center',
          children: [
            {
              title: this.$t('数量'),
              align: 'center',
              dataIndex: 'alotteryNumber',
              customCell: (r, i) => {
                return {
                  style: {
                    textAlign: 'right',
                  },
                }
              },
              customRender: (text, r) => {
                text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
                return text.toFixed(0);
              }
            },
            {
              title: this.$t('A票'),
              align: 'center',
              dataIndex: 'alottery',
              customCell: (r, i) => {
                return {
                  style: {
                    textAlign: 'right',
                  },
                }
              },
              customRender: (text, r) => {
                text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
                return text.toFixed(0);
              }
            },
          ],
        },
        {
          title: this.$t('回收A币'),
          align: 'center',
          children: [
            {
              title: this.$t('数量'),
              align: 'center',
              dataIndex: 'acoinNumber',
              customCell: (r, i) => {
                return {
                  style: {
                    textAlign: 'right',
                  },
                }
              },
              customRender: (text, r) => {
                text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
                return text.toFixed(0);
              }
            },
            {
              title: this.$t('A币'),
              align: 'center',
              dataIndex: 'acoin',
              customCell: (r, i) => {
                return {
                  style: {
                    textAlign: 'right',
                  },
                }
              },
              customRender: (text, r) => {
                text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
                return text.toFixed(0);
              }
            },
          ],
        }
      ],
      giftRecycleDataSource: [],
      goodsKindColumns: [
        {
          title: this.$t('分类编码'),
          align: 'center',
          dataIndex: 'kindCode',
          customRender:(t,r)=>{
            if(t=='合计'){
              return this.$t(t)
            }
            return t
          }
        },
        {
          title: this.$t('分类名称'),
          align: 'center',
          dataIndex: 'kindName',
        },
        {
          title: this.$t('业务笔数'),
          align: 'center',
          dataIndex: 'count',
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('成本'),
          align: 'center',
          dataIndex: 'cost',
          customRender: (t) => {
            if (!t) {
              t = 0
            }
            return t.toFixed(4)
          },
          customCell: () => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('销售金额'),
          align: 'center',
          dataIndex: 'totle',
          customRender: (t) => {
            if (!t) {
              t = 0
            }
            return t.toFixed(2)
          },
          customCell: () => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('利润'),
          align: 'center',
          dataIndex: 'profit',
          customRender: (t) => {
            if (!t) {
              t = 0
            }
            return t.toFixed(2)
          },
          customCell: () => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('利润占比'),
          align: 'center',
          dataIndex: 'ratio',
          customRender: (t,r) => {
            if(!t){
              return ''
            }
            return t + '%'
          },
          customCell: () => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
      ],
      goodsKindDataSource: [],
      queryParam: {
        bTime: moment().format('YYYY-MM-DD 00:00:00'),
        eTime: moment().format('YYYY-MM-DD 23:59:59'),
      },
      //shops: [],
      isCustom: true,
      tenantid: Vue.ls.get('TENANT_ID'),
      dataSource:[],
      defModules: [],
      modules: [],
      settingModules: [],
    }
  },
  mounted() {
    let that = this
    if (localStorage.getItem('operateCoin') == 1) {
      this.businessSummaryColumns.splice(this.businessSummaryColumns.length-1, 0, {
        title: this.$t('代币'),
        align: 'center',
        dataIndex: 'coin',
        customRender: (t, r, i) => {
          if (!t) {
            t = 0
          }
          return t.toFixed(2)
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      })
      this.goodsSalesColumns.splice(this.goodsSalesColumns.length, 0, {
        title: this.$t('扣币'),
        align: 'center',
        dataIndex: 'coin',
        customRender: (t, r, i) => {
          if (!t) {
            t = 0
          }
          return t.toFixed(2)
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      })
      this.balanceChangesColumns.splice(this.balanceChangesColumns.length, 0, {
        title: this.$t('币值'),
        align: 'center',
        dataIndex: 'coin',
        customRender: (t, r, i) => {
          if (!t) {
            t = 0
          }
          return t.toFixed(2)
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      })
    }
    // 业务汇总
    if (localStorage.getItem('operateLottery') == 1) {
      this.businessSummaryColumns.splice(this.businessSummaryColumns.length-1, 0, {
          title: this.$t('彩票'),
          align: 'center',
          dataIndex: 'lottery',
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        customRender: (text, r) => {
          text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
          return text.toFixed(0);
        }
        })
      this.goodsSalesColumns.splice(this.goodsSalesColumns.length, 0, {
        title: this.$t('扣彩票'),
        align: 'center',
        dataIndex: 'lottery',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
          return text.toFixed(0);
        }
      })
      this.balanceChangesColumns.splice(this.balanceChangesColumns.length, 0, {
        title: this.$t('票值'),
        align: 'center',
        dataIndex: 'lottery',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
          return text.toFixed(0);
        }
      })
    }
    if (localStorage.getItem('operateCredit') == 1) {
      this.businessSummaryColumns.splice(this.businessSummaryColumns.length-1, 0, {
        title: this.$t('积分'),
        align: 'center',
        dataIndex: 'integral',
        customRender: (t, r, i) => {
          if (!t) {
            t = 0
          }
          return t.toFixed(2)
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      })
      this.goodsSalesColumns.splice(this.goodsSalesColumns.length, 0, {
        title: this.$t('扣积分'),
        align: 'center',
        dataIndex: 'integral',
        customRender: (t, r, i) => {
          if (!t) {
            t = 0
          }
          return t.toFixed(2)
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },

      })
      this.balanceChangesColumns.splice(this.balanceChangesColumns.length, 0, {
        title: this.$t('积分'),
        align: 'center',
        dataIndex: 'integral',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
          return text.toFixed(0);
        }
      })
    }
    if (localStorage.getItem('operateALottery') == 1) {
      this.businessSummaryColumns.splice(this.businessSummaryColumns.length-1, 0, {
        title: this.$t('A票'),
        align: 'center',
        dataIndex: 'alottery',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
          return text.toFixed(0);
        }
      })
      this.goodsSalesColumns.splice(this.goodsSalesColumns.length, 0, {
        title: this.$t('扣A票'),
        align: 'center',
        dataIndex: 'alottery',
        customRender: (t, r, i) => {
          if (!t) {
            t = 0
          }
          return t.toFixed(2)
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      })
      this.balanceChangesColumns.splice(this.balanceChangesColumns.length, 0, {
        title: this.$t('A票'),
        align: 'center',
        dataIndex: 'alottery',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
          return text.toFixed(0);
        }
      })
    }
    if (localStorage.getItem('operateACoin') == 1) {
      this.businessSummaryColumns.splice(this.businessSummaryColumns.length-1, 0, {
        title: this.$t('A币'),
        align: 'center',
        dataIndex: 'points',
        customRender: (t, r, i) => {
          if (!t) {
            t = 0
          }
          return t.toFixed(2)
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      })
      this.goodsSalesColumns.splice(this.goodsSalesColumns.length, 0, {
        title: this.$t('扣A币'),
        align: 'center',
        dataIndex: 'point',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
          return text.toFixed(0);
        }
      })
      this.balanceChangesColumns.splice(this.balanceChangesColumns.length, 0, {
        title: this.$t('A币'),
        align: 'center',
        dataIndex: 'acoin',
        customRender: (t, r, i) => {
          if (!t) {
            t = 0
          }
          return t.toFixed(2)
        },
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
      })
    }
    // 门票汇总
    if (localStorage.getItem('operateCoin') == 1) {
      this.ticketProjectColumns.splice(this.ticketProjectColumns.length - 1, 0, {
        title: this.$t('币兑换数量'),
        align: 'center',
        dataIndex: 'coinNum',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text == null || text == "" || text == undefined) ? 0 : parseFloat(text);
          return text.toFixed(2);
        }
      }, {
        title: this.$t('扣币值'),
        align: 'center',
        dataIndex: 'coin',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text == null || text == "" || text == undefined) ? 0 : parseFloat(text);
          return text.toFixed(2);
        }
      })
    }
    if (localStorage.getItem('operateLottery') == 1) {
      this.ticketProjectColumns.splice(this.ticketProjectColumns.length - 1, 0, {
        title: this.$t('彩票兑换数量'),
        align: 'center',
        dataIndex: 'lotteryNum',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text == null || text == "" || text == undefined) ? 0 : parseFloat(text);
          return text.toFixed(0);
        }
      }, {
        title: this.$t('扣票值'),
        align: 'center',
        dataIndex: 'lottery',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text == null || text == "" || text == undefined) ? 0 : parseFloat(text);
          return text.toFixed(0);
        }
      })
    }
    if (localStorage.getItem('operateCredit') == 1) {
      this.ticketProjectColumns.splice(this.ticketProjectColumns.length - 1, 0, {
        title: this.$t('积分兑换数量'),
        align: 'center',
        dataIndex: 'integralNum',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text == null || text == "" || text == undefined) ? 0 : parseFloat(text);
          return text.toFixed(0);
        }
      }, {
        title: this.$t('扣积分值'),
        align: 'center',
        dataIndex: 'integral',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text == null || text == "" || text == undefined) ? 0 : parseFloat(text);
          return text.toFixed(0);
        }
      })
    }
    if (localStorage.getItem('operateACoin') == 1) {
      this.ticketProjectColumns.splice(this.ticketProjectColumns.length - 1, 0, {
        title: this.$t('A币兑换数量'),
        align: 'center',
        dataIndex: 'pointNum',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text == null || text == "" || text == undefined) ? 0 : parseFloat(text);
          return text.toFixed(0);
        }
      }, {
        title: this.$t('扣A币'),
        align: 'center',
        dataIndex: 'point',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text == null || text == "" || text == undefined) ? 0 : parseFloat(text);
          return text.toFixed(0);
        }
      })
    }
    if (localStorage.getItem('operateALottery') == 1) {
      this.ticketProjectColumns.splice(this.ticketProjectColumns.length - 1, 0, {
        title: this.$t('A票兑换数量'),
        align: 'center',
        dataIndex: 'alotteryNum',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text == null || text == "" || text == undefined) ? 0 : parseFloat(text);
          return text.toFixed(0);
        }
      }, {
        title: this.$t('扣A票'),
        align: 'center',
        dataIndex: 'alottery',
        customCell: (r, i) => {
          return {
            style: {
              textAlign: 'right',
            },
          }
        },
        customRender: (text, r) => {
          text = (text == null || text == "" || text == undefined) ? 0 : parseFloat(text);
          return text.toFixed(0);
        }
      })
    }
    that.searchQuery()
    /* document.onkeydown = function (e) {
      let key = window.event.keyCode
      if (key == 75 && event.ctrlKey) {
        window.event.preventDefault()
        that.isHideData = false
        that.queryParam.dataType = 0
        that.searchQuery()
      }
    } */
  },
  watch: {
    dataSource(nVal) {
      this.equipmentCollectionColumns = [
        {
          title: this.$t('设备编码'),
          align: 'center',
          dataIndex: 'deviceId',
        },
        {
          title: this.$t('设备名称'),
          align: 'center',
          dataIndex: 'deviceName',
        },
      ]
      if (nVal.length > 0 && nVal[0].payTypeList.length > 0) {
        nVal[0].payTypeList.forEach((pt) => {
          let dtl = {
            title: this.$t(pt.payTypeName),
            align: 'center',
            dataIndex: 'tit' + pt.payType,
            customRender: (t, r, i) => {
              if (!r['cash'+pt.payType]) {
                r['cash'+pt.payType] = 0
              }
              return r['cash'+pt.payType].toFixed(2)+'/'+r['num'+pt.payType]
            },
            customCell: (r, i) => {
              return {
                style: {
                  textAlign: 'right',
                },
              }
            },
          }
          this.equipmentCollectionColumns.push(dtl)
        })
        let tdtl = {
          title: this.$t("其中税费"),
          align: 'center',
          dataIndex: 'tax',
          customRender: (t, r, i) => {
            return t.toFixed(2)
          },
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        }
        if(localStorage.getItem('taxSetting') != 0){
          this.equipmentCollectionColumns.push(tdtl)
        }
      }
      this.equipmentCollectionDataSource = []
      this.orgData(nVal, 0)
    },
  },
  methods: {
    viewDetail() {
      let dtl = Object.assign({}, this.queryParam)
      this.$refs.sDtlModal.show(dtl)
    },
    orgData(list, i) {
      if (i <= list.length - 1) {
        let data = {}
        data.deviceId = list[i].deviceId
        data.deviceName = list[i].deviceName
        this.equipmentCollectionDataSource.push(data)
        this.orgData1(list, 0, i)
      }
    },
    orgData1(list, i, j) {
      if (i <= list[j].payTypeList.length - 1) {
        list[j].payTypeList.forEach((lt) => {
          this.$set(this.equipmentCollectionDataSource[j], 'cash' + lt.payType, lt.pay)
          this.$set(this.equipmentCollectionDataSource[j], 'num' + lt.payType, lt.num)
          if(lt.payType == 0){
            this.$set(this.equipmentCollectionDataSource[j], 'tax', lt.tax)
          }
        })
        i++
        this.orgData1(list, i, j)
      } else if (j < list.length - 1) {
        j++
        this.orgData(list, j)
      }
    },
    initDictConfig() {
      this.customInit()
      initDictOptions('SiteReport.modules').then((res) => {
        if (res.success) {
          this.defModules = res.result;
          console.log(this.defModules)
          this.initColumns();
        }
      })
    },
    onColSettingsChange(checkedValues) {
      var key = this.$route.name + ':colsettings'
      Vue.ls.set(key, checkedValues, 7 * 24 * 60 * 60 * 1000)
      this.settingModules = checkedValues
      const cols = this.defModules.filter((item) => {
        if (this.settingModules.includes(item.value)) {
          return true
        }
        return false
      })
      this.modules = cols
    },
    initColumns() {
      //权限过滤（列权限控制时打开，修改第二个参数为授权码前缀）
      var key = this.$route.name + ':colsettings'
      let colSettings = Vue.ls.get(key)
      if (colSettings == null || colSettings == undefined) {
        let settingModules = []
        this.defModules.forEach(function (item, i, array) {
          settingModules.push(item.value)
        })
        this.settingModules = settingModules
        this.modules = this.defModules
      } else {
        this.settingModules = colSettings
        const cols = this.defModules.filter((item) => {
          if (colSettings.includes(item.value)) {
            return true
          }
          return false
        })
        this.modules = cols
      }
    },
    customInit() {
      this.searchQuery()
    },
    customRow(r, i, k) {
      return {
        on: {
          click: () => {
            let x = this.selectedRowIndex.findIndex(r=>{return r==k+this.ipagination.current+''+i})
            if( x == -1 ){
              this.selectedRowIndex.push(k+this.ipagination.current+''+i)
            }else{
              this.selectedRowIndex.splice(x, 1)
            }
          }
        },
        style: {
          whiteSpace: 'break-spaces',
          wordBreak: 'break-word',
          overflowWrap: 'break-word',
          backgroundColor: this.selectedRowIndex.findIndex(r=>{return r==k+this.ipagination.current+''+i}) > -1 ? '#FFECE6' : '',
          fontWeight:
            r.deviceId == this.$t('合计') ||
              r.typeId_dictText == this.$t('合计') ||
              r.goodsForm == this.$t('合计') ||
              r.kindCode == this.$t('合计') ||
              r.goodsName == this.$t('合计')
              ? 700: 400,
        },
      }
    },
    customRow1(r, i, k) {
      return {
        on: {
          click: () => {
            let x = this.selectedRowIndex.findIndex(r=>{return r==k+this.ipagination.current+''+i})
            if( x == -1 ){
              this.selectedRowIndex.push(k+this.ipagination.current+''+i)
            }else{
              this.selectedRowIndex.splice(x, 1)
            }
          }
        },
        style: {
          whiteSpace: 'break-spaces',
          wordBreak: 'break-word',
          overflowWrap: 'break-word',
          backgroundColor: this.selectedRowIndex.findIndex(r=>{return r==k+this.ipagination.current+''+i}) > -1 ? '#FFECE6' : '',
          fontWeight: !r.gameId ? 700 : 400,
        },
      }
    },
    searchQuery() {
      this.selectedRowIndex = []
      this.equipmentCollection()
      this.businessSummary()
      this.goodsSales()
      this.machineOnOff()
      this.ticketProject()
      this.balanceChanges()
      this.getMemberMeal()
      this.deviceOutCoin()
      this.saveLottery()
      this.giftRecycle()
      this.goodsKind()
    },
    handleExportXls(fileName){
      if(!fileName || typeof fileName != "string"){
        fileName = this.$t('导出文件')
      }
      downFile("/report/shop/a/exportXls",{
        beginTime: this.queryParam.bTime,
        endTime: this.queryParam.eTime,
        hideModules: this.getColumnField('modules','defModules')
      }).then((data)=>{
        if (!data) {
          this.$message.warning(this.$t('文件下载失败'))
          return
        }
        if (typeof window.navigator.msSaveBlob !== 'undefined') {
          window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls')
        }else{
          let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'}))
          let link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', fileName+'.xls')
          document.body.appendChild(link)
          link.click()
          document.body.removeChild(link); //下载完成移除元素
          window.URL.revokeObjectURL(url); //释放掉blob对象
        }
      })
    },
    equipmentCollection() {
      let that = this
      getAction('/report/shop/a/deviceCollection/list', {
        beginTime: that.queryParam.bTime,
        endTime: that.queryParam.eTime,
      }).then((res) => {
        if (res.success) {
          that.dataSource=res.result
        }
      })
    },
    businessSummary() {
      let that = this
      getAction('/report/day/businessTypeTotal/list', {
        bTime: that.queryParam.bTime,
        eTime: that.queryParam.eTime,
        pageSize: 99999999,
      }).then((res) => {
        if (res.success) {
          let sum = {
            typeId_dictText: that.$t('合计'),
            count: 0,
            cash: 0,
            coin: 0,
            lottery: 0,
            integral: 0,
            points: 0,
            alottery: 0,
            phyCoin: 0
          }
          res.result.records.forEach((rs) => {
            sum.count += rs.count
            sum.cash += rs.cash
            sum.coin += rs.coin
            sum.lottery += rs.lottery
            sum.integral += rs.integral
            sum.points += rs.points
            sum.alottery += rs.alottery
            sum.phyCoin += rs.phyCoin
          })
          that.businessSummaryDataSource = res.result.records
          if (res.result.total > 0) {
            that.businessSummaryDataSource.push(sum)
          }
        }
      })
    },
    goodsSales() {
      let that = this
      getAction('/report/day/goodsSaleConvert/list', {
        bTime: that.queryParam.bTime,
        eTime: that.queryParam.eTime,
      }).then((res) => {
        if (res.success) {
          that.goodsSalesDataSource = res.result
        }
      })
    },
    machineOnOff() {
      let that = this
      getAction('/game/bisGameCoinRecord/getReport', {
        createTime_begin: that.queryParam.bTime,
        createTime_end: that.queryParam.eTime,
        groupBy: 'game_type_id,game_id,output_type',
      }).then((res) => {
        if (res.success) {
          that.machineOnOffDataSource = res.result.records
        }
      })
    },
    ticketProject() {
      let that = this
      getAction('/report/day/gameTicketSummary/list', {
        bTime: that.queryParam.bTime,
        eTime: that.queryParam.eTime,
        pageSize: 99999999,
      }).then((res) => {
        if (res.success) {
          that.ticketProjectDataSource = res.result
        }
      })
    },
    balanceChanges(){
      let that = this
      getAction('/report/shop/a/memberReport/list', {
        beginTime: that.queryParam.bTime,
        endTime: that.queryParam.eTime
      }).then((res) => {
        if (res.success) {
          let dtl=res.result[0],list=[]
          list.push({
            name:that.$t('期初'),
            member:dtl.initialMember,
            coin:dtl.initialCoin,
            lottery:dtl.initialLottery,
            integral:dtl.initialIntegral,
            acoin:dtl.initialACoin,
            alottery:dtl.initialALottery
          })
          list.push({
            name:that.$t('本期增'),
            member:dtl.addMember,
            coin:dtl.addCoin,
            lottery:dtl.addLottery,
            integral:dtl.addIntegral,
            acoin:dtl.addACoin,
            alottery:dtl.addALottery
          })
          list.push({
            name:that.$t('本期减'),
            member:dtl.subMember,
            coin:dtl.subCoin,
            lottery:dtl.subLottery,
            integral:dtl.subIntegral,
            acoin:dtl.subACoin,
            alottery:dtl.subALottery
          })
          list.push({
            name:that.$t('变化值'),
            member:dtl.changeMember,
            coin:dtl.changeCoin,
            lottery:dtl.changeLottery,
            integral:dtl.changeIntegral,
            acoin:dtl.changeACoin,
            alottery:dtl.changeALottery
          })
          list.push({
            name:that.$t('期末'),
            member:dtl.finalMember,
            coin:dtl.finalCoin,
            lottery:dtl.finalLottery,
            integral:dtl.finalIntegral,
            acoin:dtl.finalACoin,
            alottery:dtl.finalALottery
          })
          that.balanceChangesDataSource = list
        }
      })
    },
    getMemberMeal(){
      let that = this
      getAction('/report/day/memberPackageSummary/getReport', {
        bTime: that.queryParam.bTime,
        eTime: that.queryParam.eTime,
        goodsForm: '2,3,4,5,8',
        groupBy: 'goods_id'
      }).then((res) => {
        if (res.success) {
          that.memberMealDataSource = res.result
        }
      })
    },
    deviceOutCoin(){
      let that = this
      getAction('/goods/bisOrderPhysicalCoin/getReport', {
        bTime: that.queryParam.bTime,
        eTime: that.queryParam.eTime,
      }).then((res) => {
        if (res.success) {
          that.outCoinDataSource = res.result
        }
      })
    },
    saveLottery() {
      let that = this
      getAction('/report/day/memberDepositSummary/list', {
        bTime: that.queryParam.bTime,
        eTime: that.queryParam.eTime,
        pageSize: 99999999,
      }).then((res) => {
        if (res.success) {
          that.saveLotteryDataSource = res.result
        }
      })
    },
    giftRecycle() {
      let that = this
      getAction('/member/bisGiftReclaimRecord/getReportList', {
        bTime: that.queryParam.bTime,
        eTime: that.queryParam.eTime,
      }).then((res) => {
        if (res.success) {
          that.giftRecycleDataSource = res.result
        }
      })
    },
    goodsKind() {
      let that = this
      getAction('/report/goods/goodsKindSummary/list', {
        bTime: that.queryParam.bTime,
        eTime: that.queryParam.eTime,
        pageSize: 99999999,
      }).then((res) => {
        if (res.success) {
          that.goodsKindDataSource = res.result
        }
      })
    },
    handleDateClick(evt){
      if(evt.key=='1'){
        this.queryParam.bTime=moment().format('YYYY-MM-DD 00:00:00')
        this.queryParam.eTime=moment().format('YYYY-MM-DD 23:59:59')
      }
      if(evt.key=='2'){
        this.queryParam.bTime=moment().subtract(2,'day').format('YYYY-MM-DD 00:00:00')
        this.queryParam.eTime=moment().format('YYYY-MM-DD 23:59:59')
      }
      if(evt.key=='3'){
        this.queryParam.bTime=moment().subtract(6,'day').format('YYYY-MM-DD 00:00:00')
        this.queryParam.eTime=moment().format('YYYY-MM-DD 23:59:59')
      }
      if(evt.key=='4'){
        this.queryParam.bTime=moment().subtract(1, 'month').format('YYYY-MM-DD 00:00:00')
        this.queryParam.eTime=moment().format('YYYY-MM-DD 23:59:59')
      }
      if(evt.key=='5'){
        this.queryParam.bTime=moment().subtract(3,'month').format('YYYY-MM-DD 00:00:00')
        this.queryParam.eTime=moment().format('YYYY-MM-DD 23:59:59')
      }
      if(evt.key=='6'){
        this.queryParam.bTime=moment().subtract(6,'month').format('YYYY-MM-DD 00:00:00')
        this.queryParam.eTime=moment().format('YYYY-MM-DD 23:59:59')
      }
      if(evt.key=='7'){
        this.queryParam.bTime=moment().startOf('year').format('YYYY-MM-DD 00:00:00')
        this.queryParam.eTime=moment().format('YYYY-MM-DD 23:59:59')
      }
      this.searchQuery()
    },
    handlePrint(){
      this.$refs.printPreview.show({
        queryParam: this.queryParam,
        modules: this.modules,
        equipmentCollectionColumns: this.equipmentCollectionColumns,
        equipmentCollectionDataSource: this.equipmentCollectionDataSource,
        businessSummaryColumns: this.businessSummaryColumns,
        businessSummaryDataSource: this.businessSummaryDataSource,
        goodsSalesColumns: this.goodsSalesColumns,
        goodsSalesDataSource: this.goodsSalesDataSource,
        machineOnOffColumns: this.machineOnOffColumns,
        machineOnOffDataSource: this.machineOnOffDataSource,
        ticketProjectColumns: this.ticketProjectColumns,
        ticketProjectDataSource: this.ticketProjectDataSource,
        balanceChangesColumns: this.balanceChangesColumns,
        balanceChangesDataSource: this.balanceChangesDataSource,
        memberMealColumns: this.memberMealColumns,
        memberMealDataSource: this.memberMealDataSource,
        outCoinColumns: this.outCoinColumns,
        outCoinDataSource: this.outCoinDataSource,
        saveLotteryColumns: this.saveLotteryColumns,
        saveLotteryDataSource: this.saveLotteryDataSource,
        giftRecycleColumns: this.giftRecycleColumns,
        giftRecycleDataSource: this.giftRecycleDataSource,
        goodsKindColumns: this.goodsKindColumns,
        goodsKindDataSource: this.goodsKindDataSource
      })
    },
    getColumnField(key,dkey){
      let arr=[],str=''
      this[dkey].forEach(dk=>{
        let x= this[key].findIndex(k=>{
          return dk.value==k.value
        })
        if(x==-1){
          arr.push(dk)
        }
      })
      str=arr.map(a=>{return a.value}).join(',')
      return str
    }
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>